using System;
using System.Collections.Generic;
using System.Text;

namespace InSTEDD.Labs.Geo
{
    public class PolygonBuilder
    {
        public static Polygon FromKMLString(string coordList)
        {
            Polygon poly = new Polygon();

            //-122.136246,37.473667,0 -122.135361,37.473682,0 -122.135345,37.472313,0 -122.135254,37.47197300000001,0 -122.135124,37.471783,0 -122.136147,37.471767,0 -122.136246,37.473667,0
            string[] points = coordList.Trim().Split(' ');
            foreach (string pointStr in points)
            {
                string[] coordsStr = pointStr.Split(',');

                poly.Points.Add(new PPoint(double.Parse(coordsStr[0]), double.Parse(coordsStr[1])));
            }

            return poly;
        }

    }
}
